<?php
namespace app\index\controller;
use app\index\model\platformTable;
use app\index\model\productTable;
class Disposition extends Common
{
	public function platform(){
		return view();
	}
	public function platformData(){
		$page = request()->param('page');
		$limit = request()->param('limit');
		$start = ($page-1)*$limit;
		$ddh = request()->param('value');
		if($ddh == ''){
			$userinfo = platformTable::limit($start,$limit)->order('create_time','desc')->select();
			$count = count(platformTable::select());
		}else{
			$userinfo = platformTable::withSearch(['platform'],['platform'=>$ddh])->limit($start,$limit)->order('create_time','desc')->select();
			$count = count(platformTable::withSearch(['platform'],['platform'=>$ddh])->select());
			
		}
		
		$msg = [
			'code'=>0,
			'msg'=>'查询成功',
			'data'=>$userinfo,
			'count'=>$count
		];
		echo json_encode($msg);die;
	}
	public function platformadd(){
		return view();
	}
	public function platformaddData(){
		$data = request()->param();
		return (new platformTable())->platformaddData($data);
	}
	public function platformedit(){
		$id = request()->param('id');
		$res = platformTable::where('id',$id)->find();
		$this->assign('res',$res);
		return view();
	}
	public function platformeditData(){
		$data = request()->param();
		return (new platformTable())->platformeditData($data);
	}
	public function platformdel(){
		$id = request()->param('id');
		return (new platformTable())->platformdel($id);
	}
	
	public function product(){
		return view();
	}
	public function productData(){
		$page = request()->param('page');
		$limit = request()->param('limit');
		$start = ($page-1)*$limit;
		$ddh = request()->param('value');
		if($ddh == ''){
			$userinfo = productTable::limit($start,$limit)->order('create_time','desc')->select();
			$count = count(productTable::select());
		}else{
			$userinfo = productTable::withSearch(['product_name'],['product_name'=>$ddh])->limit($start,$limit)->order('create_time','desc')->select();
			$count = count(productTable::withSearch(['product_name'],['product_name'=>$ddh])->select());
			
		}
		
		$msg = [
			'code'=>0,
			'msg'=>'查询成功',
			'data'=>$userinfo,
			'count'=>$count
		];
		echo json_encode($msg);die;
	}
	public function productadd(){
		return view();
	}
	public function productaddData(){
		$data = request()->param();
		return (new productTable())->productaddData($data);
	}
	public function productedit(){
		$id = request()->param('id');
		$res = productTable::where('id',$id)->find();
		$this->assign('res',$res);
		return view();
	}
	public function producteditData(){
		$data = request()->param();
		return (new productTable())->producteditData($data);
	}
	public function productdel(){
		$id = request()->param('id');
		return (new productTable())->productdel($id);
	}
}